from django import forms

from demo.models import Classes, Label


class ArticleForms(forms.Form):
    title=forms.CharField(
        label="标题",
        max_length=30,
        min_length=2,
        error_messages={
            'min_length': "长度小于2",
            'max_length': "长度大于30",
        }
    )
    desc=forms.CharField(
        label="文章简介",
        max_length=100,
        min_length=10,
        error_messages={
            'min_length': "长度小于10",
            'max_length': "长度大于100",
        }
    )
    content=forms.CharField(
        label="内容",
        widget=forms.Textarea
    )
    cover=forms.FileField(
        label="封面图"
    )
    # 分类应该是让用户选择的
    classes=forms.ModelChoiceField(
        label="分类",
        queryset=Classes.objects.all(),
        empty_label=None,
    )
    # 多对多 多选字段
    label=forms.ModelMultipleChoiceField(
        label="标签",
        queryset=Label.objects.all()
    )




































